package com.me.data;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class MeEvent {

	private long eventId;
	private String title;
	private int allDay;
	private long start;
	private long end;
	private Calendar calStart;
	private Calendar calEnd;
	private String venue;

	public MeEvent() {
	}

	public MeEvent(long eventId, String title, int allDay, long start,
			long end, String venue) {
		super();
		this.eventId = eventId;
		this.title = title;
		this.allDay = allDay;

		this.start = start;
		this.calStart = Calendar.getInstance();
		calStart.setTimeInMillis(start);

		this.end = end;
		this.calEnd = Calendar.getInstance();
		calEnd.setTimeInMillis(end);

		this.venue = venue;
	}

	public long getEventId() {
		return eventId;
	}

	public String getEventStringId() {
		return String.valueOf(eventId);
	}
	
	public String getTitle() {
		return title;
	}

	public boolean isAllDay() {
		return (allDay == 1);
	}

	public long getStart() {
		return start;
	}

	public String getFormattedStart(String format) {
		SimpleDateFormat formatter = new SimpleDateFormat(format);
		return formatter.format(calStart.getTime());
	}

	public Calendar getCalStart() {
		return calStart;
	}

	public long getEnd() {
		return end;
	}

	public String getFormattedEnd(String format) {
		SimpleDateFormat formatter = new SimpleDateFormat(format);
		return formatter.format(calEnd.getTime());
	}

	public Calendar getCalEnd() {
		return calEnd;
	}

	public String getVenue() {
		return venue;
	}

	public String toString() {
		
		StringBuffer infoBuffer = new StringBuffer();
		infoBuffer.append("Title: ");
		infoBuffer.append(title);
		if (allDay == 1) {
			infoBuffer.append("\nDate: ");
			infoBuffer.append(getFormattedStart("yyyy-MM-dd"));
		} else {
			infoBuffer.append("\nStart Time: ");
			infoBuffer.append(getFormattedStart("yyyy-MM-dd EEE HH:mm"));
			infoBuffer.append("\nEnd Time: ");
			infoBuffer.append(getFormattedEnd("yyyy-MM-dd EEE HH:mm"));
		}

		if (venue != null && venue.length() > 0) {
			infoBuffer.append("\nVenue: ");
			infoBuffer.append(venue);
		}
		return infoBuffer.toString();		
	}

	
	//test title
	public void setTitle(String title) {
		this.title = title;
	}
	
	//test venue	
	public void setVenue(String venue) {
		this.venue = venue;
	}

}
